package com.xpffly.design.factory.base.factory;

import com.xpffly.design.factory.base.service.Human;

/**
 * @Author: xpengfei
 * @Date: 2021/3/26 22:40
 * @Description：人类对象创建工厂
 */
public class HumanFactory extends AbstractHumanFactory {

    @Override
    public <T extends Human> T createHuman(Class<T> tClass) {
        // 定义一个待生产的人种
        Human human = null;
        try {
            // 产生第一个人种
            human = (Human) Class.forName(tClass.getName()).newInstance();
        } catch (Exception e) {
            System.out.println("人种生产失败！" + e.getMessage());
        }
        return (T) human;
    }
}
